function checkUser(texts){
   var str = texts.value;
   var reg= /^[a-z0-9]*$/;
   if(!reg.test(str)){
   	//alert('if num and param');
       return false;
   } 
   var tStr = /^[a-z]*$/;   
   var iVal = str.charAt(0);
   if(!tStr.test(iVal)){
   	//alert('first is param');
       return false;
   }
   return true;
}

function checkLen(texts){
   var str = texts.value;
   var num = str.length;
   var arr=str.match(/[^\x00-\x80]/ig);
   if(arr!=null){
      num += arr.length;
   }
   return num;
}

function isEqual(texts1,texts2)
{
   if(texts1.value != texts2.value)
   {
       texts1.focus();
       return false;
   }
   return true;
}

function checkEmail(texts){
  var str = texts.value;
  var pattern = /^[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)*@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+){1,4}$/;
  return pattern.test(str);
}

function checkEmailval(str){
  var pattern = /^[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)*@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+){1,4}$/;
  return pattern.test(str);
}

function isInt(texts)
{
   var reg = /[^0-9]/;
   if(reg.test(texts.value))return true;
   return false;
}

function checkDate(texts){ 
  var tempTexts = texts.value;
  var myStr = tempTexts.match(/^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})$/); 
  if(myStr == null)
  {
     texts.focus();
     return false;
  }
  var d = new Date(myStr[1], myStr[3]-1, myStr[4]); 
  if(!d.getFullYear() == myStr[1] && (d.getMonth()+1) == myStr[3] && d.getDate() == myStr[4])
  {
     texts.focus();
     return false;
  }
  return true;
}
function openwin(url)
{
    prop="status=yes,location=no,scrollbar=no,menubar=no,scrollbars=yes,left=100,top=100,height=420,width=750";
    window.open(url,'',prop);
}

function openwin2(url)
{
    prop="status=yes,location=no,scrollbar=no,menubar=no,scrollbars=yes,left=100,top=100,height=300,width=500";
    window.open(url,'',prop);
}

function checkmember(texts){
   var str = texts;
   var reg= /^[a-z0-9]*$/;
   if(!reg.test(str)){
   	//alert('if num and param');
       return false;
   } 
   var tStr = /^[a-z]*$/;   
   var iVal = str.charAt(0);
   if(!tStr.test(iVal)){
   	//alert('first is param');
       return false;
   }
   return true;
}

function checkLenvalue(texts){
   var str = texts;
   var num = str.length;
   var arr=str.match(/[^\x00-\x80]/ig);
   if(arr!=null){
      num += arr.length;
   }
   return num;
}

function ajax_check_name($name,$obj,$submit_obj,url,_html){
	if(!checkmember($name)){$obj.html(_html[4]);$submit_obj.attr('disabled','disabled');return false;}
	if(checkLenvalue($name)<=4){$obj.html(_html[5]);$submit_obj.attr('disabled','disabled');return false;}
	$.ajax({
		url:url,
		data:{name:$name},
		type:'post',
		beforeSend:function(){$obj.html(_html[1])},
		success:function(msg){
			if(msg=='1'){$obj.html(_html[2]);$submit_obj.attr('disabled','disabled');return false;}else{
				$obj.html(_html[3]);$submit_obj.attr('disabled',false);return true;
			}
		}
	})
}

function ajax_check_email($name,$obj,$submit_obj,url,_email){
	if(!checkEmailval($name)){$obj.html(_email[4]);$submit_obj.attr('disabled','disabled');return false;}
	$.ajax({
		url:url,
		data:{name:$name},
		type:'post',
		beforeSend:function(){$obj.html(_email[1])},
		success:function(msg){
			if(msg=='1'){$obj.html(_email[2]);$submit_obj.attr('disabled','disabled');return false;}else{
				$obj.html(_email[3]);$submit_obj.attr('disabled',false);return true;
			}
		}
	})
}